#pragma once
#ifndef CGUITEXTBOX_H_
#define CGUITEXTBOX_H_

#include "GUI.h"

namespace GUI
{
	class CGUITextBox : public CGUIBase{  
	private:
		std::string m_TextDraw;
		std::vector<std::string> m_Text;
		bool m_bEditable, m_bSelectable, m_bCaretOn;
		UINT m_Caretx, m_Carety, m_SelStartx, m_SelStarty, m_CaretBlink, m_MaxCaretx, m_MaxCarety, m_Scrollx, m_Scrolly;
		UINT m_Event;
		void* m_pDest;
	public:
		CGUITextBox(GUI_PARAMS* params, GUI_COLORS* _colors, GUI_SPRITES* _sprites, bool _editable, bool _selectable, UINT _event, void* _dest, LPCSTR _text);
		~CGUITextBox();

		virtual bool WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
		virtual bool HandleKeyboard( UINT uMsg, WPARAM wParam, LPARAM lParam );
		virtual bool HandleMouse( UINT uMsg, WPARAM wParam, LPARAM lParam );

		virtual bool RequestFocus();
		virtual bool CanHaveFocus();
		virtual void OnFocusIn();
		virtual void OnFocusOut();
		virtual void OnMouseEnter();
		virtual void OnMouseLeave();
		virtual void OnHotkey();

		void SetText(std::string _text);
		void AddLine(std::string _text);
		void AddText(std::string _text);
		void AddChar(char _text);
		void SetTextDraw();
		std::string Getline(int _line){ return m_Text[_line]; }
		void PlaceCaret(int _x, int _y);
		void PlaceCaret(POINT _cursor);
		void SyncSelStart();
		void DeleteSelectionText();
		void DeleteTextAtCaret();

		virtual void Step();
		virtual void Draw();
	};
}

#endif